home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Rice_CMS / gopher24 / gopsrvrp.$rexx < prev    next >
Encoding:
Text File  |  1993-01-25  |  7.4 KB  |  95 lines

  1. /*                                                                      00010000
  2.  *        Name: GOPSRVRP REXX                                           00020000
  3.  *              resolve gopher paths (selector strings) recursively     00030000
  4.  *      Author: Rick Troth, Rice University, Information Systems        00040000
  5.  *        Date: 1993-Jan-15, 19                                         00050000
  6.  *                                                                      00060000
  7.  *              This file is part of CMS Gopher.                        00070000
  8.  */                                                                     00080000
  9.                                                                         00090000
  10. /*                                                                      00100000
  11.  *      Copyright 1993 Richard M. Troth.   This software was developed  00110000
  12.  *      with resources provided by Rice University and is intended      00120000
  13.  *      to serve Rice's user community.   Rice has benefitted greatly   00130000
  14.  *      from the free distribution of software,  therefore distribution 00140000
  15.  *      of unmodified copies of this material is not restricted.        00150000
  16.  *      You may change your own copy as needed.   Neither Rice          00160000
  17.  *      University nor any of its employees or students shall be held   00170000
  18.  *      liable for damages resulting from the use of this software.     00180000
  19.  */                                                                     00190000
  20.                                                                         00200000
  21. Parse Source . . arg0 .                                                 00210000
  22. Parse Arg nick '/' rest                                                 00220000
  23. nick = Strip(nick)                                                      00230000
  24. rest = Strip(rest)                                                      00240000
  25.                                                                         00250000
  26. Do While nick = ""      /*  deal with null parts w/o recursion  */      00260000
  27.     If rest = "" Then Do; 'SHORT'; Exit rc; End                         00270000
  28.     Parse Var rest nick '/' rest                                        00280000
  29.     End  /*  Do  While  */                                              00290000
  30. /*                                                                      00300000
  31. If nick = "" Then Do    **  deal with null parts by recursion  **       00310000
  32.     If rest = "" Then 'SHORT'                                           00320000
  33.                  Else 'CALLPIPE *: |' arg0 rest '| *:'                  00330000
  34.     Exit rc                                                             00340000
  35.     End  **  If  ..  Do  **                                             00350000
  36.  */                                                                     00360000
  37.                                                                         00370000
  38. /*  look for the shortcut on pure LISTFILE ouptut  */                   00380000
  39. 'PEEKTO RECORD'                                                         00390000
  40. If rc ^= 0 Then Exit rc * (rc ^= 12)                                    00400000
  41. If Strip(record) = "" Then Signal SHORTCUT                              00410000
  42.                                                                         00420000
  43. /*  part = nick;  Upper part  */                                        00430000
  44. Parse Upper Var nick part                                               00440000
  45.                                                                         00450000
  46. Do Forever                                                              00460000
  47.                                                                         00470000
  48.     'READTO RECORD'                                                     00480000
  49.     If rc ^= 0 Then Leave                                               00490000
  50.     If Left(record,1) = '*' Then Iterate                                00500000
  51.     If Left(record,1) ^= ' ' Then Leave         /*  short cut  */       00510000
  52.                                                                         00520000
  53.     Parse Upper Var record fn ft fm fp '"' . "'" . '05'x .              00530000
  54.     If Strip(fn) = "" Then Iterate                                      00540000
  55.                                                                         00550000
  56.     If  fp = "" Then  Select  /*  ft  */                                00560000
  57.         When  Index(fn,'*') > 0 Then    fp = fn || '.' || ft            00570000
  58.         When  ft = ""   | ft = "*"  | ,                                 00580000
  59.               ft = "FILELIST"   Then    fp = fn                         00590000
  60.         Otherwise                       fp = fn || '.' || ft            00600000
  61.         End  /*  Select  ft  */                                         00610000
  62.     If Strip(fp) ^= part Then Iterate                                   00620000
  63.                                                                         00630000
  64. Say "GOPSRVRP: matched" fn ft fm fp                                     00640000
  65.     /*  found it!  */                                                   00650000
  66.     /*  Parse Arg nick '/' .  */                                        00660000
  67.     Address "COMMAND" 'GLOBALV SELECT GOPHERD PUT NICK'                 00670000
  68.     If rest = "" Then 'CALLPIPE GOPSRVLS' fn ft fm '| *:'               00680000
  69.                  Else 'CALLPIPE GOPSRVLS' fn ft fm '|' arg0 rest '| *:' 00690000
  70.     /*  Leave  */  Exit rc                                              00700000
  71.                                                                         00710000
  72.     End                                                                 00720000
  73.                                                                         00730000
  74. FALLOUT:                                                                00740000
  75. Say "GOPSRVRP: didn't find a match for" nick                            00750000
  76. /*  fallout;  we didn't find a match in this menu  */                   00760000
  77. /*  Parse Arg nick  */                                                  00770000
  78. nick = nick || '/' || rest                                              00780000
  79. Address "COMMAND" 'GLOBALV SELECT GOPHERD PUT NICK'                     00790000
  80. 'CALLPIPE GOPSRVLS ? ? ? | *:'                                          00800000
  81.                                                                         00810000
  82. Exit rc                                                                 00820000
  83.                                                                         00830000
  84. SHORTCUT:                                                               00840000
  85. Parse Var                                                               00850000
  86. Say "GOPSRVRP: shortcut to" fn ft fm fp                                 00860000
  87.     /*  found it!  */                                                   00870000
  88.     /*  Parse Arg nick '/' .  */                                        00880000
  89.     Address "COMMAND" 'GLOBALV SELECT GOPHERD PUT NICK'                 00890000
  90.     If rest = "" Then 'CALLPIPE GOPSRVLS' fn ft fm '| *:'               00900000
  91.                  Else 'CALLPIPE GOPSRVLS' fn ft fm '|' arg0 rest '| *:' 00910000
  92.     /*  Leave  */  Exit rc                                              00920000
  93.                                                                         00930000
  94.                                                                         00940000
  95.